package com.shine.level.easy;

import java.util.HashMap;
import java.util.Map;

/**
 * 整形转罗马数字
 * @author zhangshao
 * @date 2021/6/29 9:18 上午
 */
public class Int2Roman {

    public static String intToRoman(int num) {
        int values [] = {1000,900,500,400,100,90,50,40,10,9,5,4,1};
        String [] romans = {"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};
        StringBuilder sb = new StringBuilder();
        for(int i =0;i<values.length;i++){
            while(num >=values[i]){
                num -=values[i];
                sb.append(romans[i]);
            }
        }
        return sb.toString();
    }
    public static void main(String[] args) {
        String s = intToRoman(8);
        System.out.println(s);

    }
}
